<template>
    <div style="background-color: white;margin: 30px;padding: 30px;">
    <el-form
      ref="ruleFormRef"
      style="max-width: 1300px"
      :model="ruleForm"
      :rules="rules"
      label-width="auto"
      class="demo-ruleForm"
      :size="formSize"
      status-icon
    >
    <el-form-item label="检查申请" prop="name">
    
        <el-table
    ref="multipleTableRef"
    :data="tableData"
    style="width: 100%"
    @selection-change="handleSelectionChange"
    size="mini"
  >
    <el-table-column    width="55" />
    <el-table-column label="分类" width="120">
       检查
    </el-table-column>
    <el-table-column property="techName" label="项目" width="120" />
    <el-table-column property="checkStatus"  width="100" label="状态" />
    <el-table-column property="checkResult"  width="100" label="检查结果" >
    </el-table-column>
    <el-table-column property="creationTime"  width="100" label="开立时间" >
    </el-table-column>
  <el-table-column label="操作" width="300">
    <template #header>
        <el-button type="success"  plain stype="margin:10px" >刷新</el-button>
    </template>
  </el-table-column> 
  </el-table>
</el-form-item>     
    </el-form>
 
</div>
  </template>
  
  <script lang="ts" setup>
  import { reactive, ref } from 'vue'
  import type { ComponentSize, FormInstance, FormRules } from 'element-plus'
  import type { TableInstance } from 'element-plus'
import axiosInstance from '@/utils/axiosUtils';
import { User } from '@element-plus/icons';
 
 // 从 sessionStorage 获取 'Patient' 数据
const patientData = sessionStorage.getItem('Patient');

// 检查是否成功获取数据，并解析为对象
const patient = patientData ? JSON.parse(patientData) : null;

// 获取 id
const registerId = patient ? patient.id : null;

console.log(registerId); // 输出 id
interface User {
    checkInfo: string
    checkPosition: string
    creationTime: boolean
    checkState: string
    checkResult: string
    checkRemark: string
    
}
 
const multipleTableRef = ref<TableInstance>()
const multipleSelection = ref<User[]>([])
    const handleSelectionChange = (val: User[]) => {
  multipleSelection.value = val
}

const tableData=reactive([
{
    checkInfo: "检查申请",
    checkPosition: "检查科室",
    creationTime: "2022-01-01",
    checkState: "已通过",
    checkResult: "检查结果",
    checkRemark: "检查备注"
  }
])
  interface RuleForm {
    name: string
    
  }
  
  const formSize = ref<ComponentSize>('default')
  const ruleFormRef = ref<FormInstance>()
  const ruleForm = reactive<RuleForm>({
    name: null,
 
  })
  const rules: FormRules = {
    name: [
      { required: true, message: '请输入项目金额', trigger: 'blur' },
      { type: 'number', message: '请输入数字', trigger: 'blur' },
    ],
  }
  const searchPatientCheck=()=>{
    axiosInstance.get('/api/checkRequest/selectPatientCheck',{
      params:{
        registerId:registerId
      }
    }).then(res=>{
      console.log(res.data)
      res.data.forEach(item=>{
        tableData.push(item)
      })
    }
    )
  }
  searchPatientCheck()
 
  </script>